import { readFile, writeFile } from 'fs'
import { resolve } from 'path'

export function outputPreset (name: string) {
  const path  = resolve(__dirname, `../preset/${name}.yaml`)
  readFile(path, { encoding: 'utf-8' }, (err, data) => {
    if (err) {
      throw err
    }
    writePreset(data)
  })
}

export function writePreset (data: string) {
  writeFile('./dsl-preset.yaml', data, { flag: 'w' }, err => {
    if (err) throw err
    console.log('preset file is created!')
  })
}
